Home:ALL Converter>What is `export type` in Typescript?

What is `export type` in Typescript?

Ask Time:2017-05-20T06:26:12         Author:hackjutsu

Json Formatter

I notice the following syntax in Typescript.

export type feline = typeof cat;

As far as I know, type is not a built-in basic type, nor it is an interface or class. Actually it looks more like a syntax for aliasing, which however I can't find reference to verify my guess.

So what does the above statement mean?

Author:hackjutsu,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44079820/what-is-export-type-in-typescript
James Monger :

This is a type alias - it's used to give another name to a type.\nIn your example, feline will be the type of whatever cat is.\nHere's a more full fledged example:\ninterface Animal {\n legs: number;\n}\n\nconst cat: Animal = { legs: 4 };\n\nexport type feline = typeof cat;\n\nfeline will be the type Animal, and you can use it as a type wherever you like.\nconst someFunc = (cat: feline) => {\n doSomething(cat.legs);\n};\n\nexport simply exports it from the file. It's the same as doing this:\ntype feline = typeof cat;\n\nexport {\n feline\n};\n",
2017-05-19T22:32:47
yy